﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DTO;
using DAL;
using BUS;
namespace WEBSITE_BANDEAL.Admin
{
    public partial class HinhAnh : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData();
            }
        }

        private void LoadData()
        {
            try
            {
             
                int ma = int.Parse(Request.QueryString["id"]);
                SAN_PHAM sp = SAN_PHAMBUS.GetByID(ma);
                Ten.Value = sp.Tensp;
                Ten.Disabled = true;
                Ma.Value = ma.ToString();

            }
            catch
            {

            }
        }

        protected void btn_Insert_Click(object sender, EventArgs e)
        {
            try
            {
                HINH_ANH ha = new HINH_ANH();
                ha.MA_SP = int.Parse(Ma.Value);
                ha.URL_HINH = HinhAnh_T.Text;
                HINH_ANHBUS.Insert(ha);
                Response.Write("<script type='text/javascript'>alert('Thêm thành công'); ; window.location.href = 'HinhAnh.aspx?id="+ Ma.Value+"' </script>");
            }
            catch
            {

            }
        }
    }
}